package com.church.daoimpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.church.dao.DevicesDao;
import com.church.db.Devices;

public class DevicesDaoImpl extends HibernateDaoSupport implements DevicesDao {

	@Override
	public String add(Devices devices) {
		this.getHibernateTemplate().save(devices);
		return "success";
	}

	@Override
	public String update(Devices devices) {
		this.getHibernateTemplate().update(devices);
		return "success";
	}

	@Override
	public Devices findById(int id) {
		List<Devices> devices = this.getHibernateTemplate().find("from Devices where id='"+id+"'");
		if(devices.size()>0)
		{
			return devices.get(0);
		}
		return null;
	}

	@Override
	public List<Devices> getList() {
		 
		return this.getHibernateTemplate().find("from Devices where state!='3'");
	}

}
